package com.waiting.generic;

/**
 * @desctiption
 * @Author bjweitingting
 * @date 2018/4/27
 **/
public class Main {
    public static void main(String[] args) {
//        Generic generic = new Generic();
//        generic.setKey("test");
//        System.out.println(generic.getKey());
//        generic.setKey(10);
//        System.out.println(generic.getKey());

        Generic<String> generic1 = new Generic<String>();
        generic1.setKey("test");
        // generic12.setKey(12); 存放int报错
        System.out.println(generic1.getKey());

        Generic<Integer> generic2 = new Generic<Integer>();

        Class class1 = generic1.getClass();
        Class class2 = generic2.getClass();
        if (class1.equals(class2)) {
            System.out.println("一样的");
        } else {
            System.out.println("不同的");
        }
        //泛型通配符
//        Generic<?> generic3 = new Generic<Object>();
//        Integer test = new Integer(12);
//        generic3.setKey(test);
//        System.out.println(generic3.getKey());

        //泛型函数调用
        try {
            GenericFunction genericFunction = new GenericFunction();
            Object object = genericFunction.genericFunction(Class.forName("com.waiting.generic.GenericFunction"));
            System.out.println(object instanceof GenericFunction);
//            genericFunction.genericFunction(new Integer(12));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
